package com.zy.chat.controller;


import com.zy.chat.service.MsgSessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

@Controller
@RequestMapping(value = "session")
public class MsgSessionController {

    @Autowired
    private MsgSessionService msgSessionService;

    @GetMapping(value = "/queryAll/{username}")
    public ResponseEntity<Map<String,Integer>> queryAll(@PathVariable(value = "username")String username){
        return new ResponseEntity<Map<String,Integer>>(this.msgSessionService.queryAll(username), HttpStatus.OK );
    }

    @GetMapping(value = "/update/{username}/{touser}/{readnum}")
    public ResponseEntity<Integer> update(@PathVariable(value = "username")String username,@PathVariable(value = "touser")String touser,@PathVariable(value = "readnum")Integer readnum){
        return new ResponseEntity<Integer>(msgSessionService.update(username,touser,readnum),HttpStatus.OK);
    }
}
